package com.thin.tomcat;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import static java.lang.System.out;

public class ServletConfig {
	private static List<ServletMapping> mappingList = new ArrayList<ServletMapping>();
	private static ConcurrentHashMap<String, String> mappingMap = new ConcurrentHashMap<String, String>();

	public static void addMapping(ServletMapping mapping) {
		String url = mapping.getUrl();
		if (url == null) {
			throw new RuntimeException("mapping url can't be null");
		}
		if (mappingMap.containsKey(url)) {
			throw new RuntimeException("mapping url " + url + " is exist");
		}
		mappingList.add(mapping);
		mappingMap.put(url, mapping.getClassz());
		out.println("mapping :"+url);
	}

	public static String getClassFullName(String mappingUrl) {
		if (mappingUrl == null)
			return null;
		return mappingMap.get(mappingUrl);
	}

}
